home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.netins.net!isac!gg
- From: gg@isac.hces.com (Greg Goodrich)
- Subject: Re: Using multiple modules
- Message-ID: <1996Mar6.001033.3452@isac.hces.com>
- Organization: Health Care Expert Systems
- X-Newsreader: TIN [version 1.2 PL2]
- References: <4h9led$b4g@news.doit.wisc.edu> <4hecka$qf2@hpbblb.bbn.hp.com>
- Date: Wed, 6 Mar 1996 00:10:33 GMT
-
- matti wrote:
- : jdscott@students.wisc.edu (Jim Scott) wrote:
- : >I'm trying to break up growing source code into multiple modules. As
- : >per the FAQ, I've moved all my external definitions to a header file
- : >included in both the modules I'm working with.
- : >
- : >I can compile the source code into separate object files, but am unable
- : >to link. I get one of two errors:
- : >
- : >"symbol defined more than once" this is in reference to the only
- : >function in the second object file. I've checked, and it is only
- : >defined in the header file.
- : >
- : >"unresolved externals" and a reference to a ??main?? file. No clue
- : >what's happening here.
- : >
- : >In the meantime, I'm simply working with the single source file. Any
- : >help is greatly appreciated!
- : >
-
- It sounds like you are defining something more than once! Don't forget
- that functions that are in the header file should only be prototypes as
- in:
-
- extern void do_this();
-
- You also should keep in mind that if you declare any variables in a
- header, you are bound to have major problems. You can extern as many
- variables as you want, but declare everything in c source files. This
- is probably giving you the trouble, based on your description. You see,
- if you declare something in a header, and 2 source files include this
- header, then they both have a declaration of the same variable. When
- you try to link, it trys to resolve all variables and finds two
- instances of one or more of them. This goes for functions as well.
- Good luck.
-
- Greg.
- --
- _______________________________________
- Greg Goodrich - gg@hces.com
- Software Engineer
- PACE Health Management Systems
-